//
//  ViewController.m
//  SXModelDemo
//
//  Created by Ganide on 2018/7/6.
//  Copyright © 2018年 Ganide. All rights reserved.
//

#import "ViewController.h"
#import "Person.h"
#import "NSObject+SX_BaseModelData.h"
#import "Car.h"
#import "Book.h"
#import "PersonMan.h"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
   CGFloat statusHeight = [[UIApplication sharedApplication] statusBarFrame].size.height;
    CGFloat height = self.tabBarController.tabBar.bounds.size.height;
   CGFloat navBar = self.navigationController.navigationBar.frame.size.height;
    
    NSString *strin = @"https://gitee.com/xiange/SXModelDemo";
    NSURL *url = [NSURL URLWithString:strin];
    CGRect rect = CGRectMake(10, 10, 20, 30);
    CGPoint point = CGPointMake(10, 10);
    
    NSDictionary *dict = @{
                           @"name":@"哈哈",
                           @"age":@20,
                           @"book":
                          @{@"name":@"方与圆",
                            @"artis":@"丁元致"},
                           @"array":@[@"hahha",@"haha2",@{@"name":@"法拉利",
                                                          @"type":@10}],
                           @"sex":@1,
                           @"number":@30,
                           @"height":@1.75,
                           @"hahhah":@"呵呵",
                           @"url":url,
                           @"car":@{@"name":@"法拉利",
                                    @"type":@10},
                         //  @"rect":@(rect),
                           @"rect":@(point),
                           @"size":@(rect)
    };
    NSArray *cars = @[
                      @{@"name":@"奥迪",
                        @"type":@13},
                      @{@"name":@"法拉利",
                        @"type":@15}];
    /*类方法 sxModelDict:*/
    
    Person *per1 = [Person sxBaseModelDictionry:dict];
    temStruct stru1 = {"struct",60};
    per1.struc = stru1;
    
  //  per1.url = url;
    NSDictionary *objDict8 = [per1 dictFromObj];
    /*对象方法 */
//    Person *per2 = [[Person alloc] sxInitBaseModelDictionry:dict];
//    /*json 数据转数据模型*/
//    NSError *err;
//    NSData *data = [NSJSONSerialization dataWithJSONObject:dict options:NSJSONWritingPrettyPrinted error:&err];
//    NSString *jsonString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
//    /*json 数据转模型 类方法*/
//    PersonMan *per3 = [PersonMan sxBaseModelJson:jsonString];
//    /*json 数据转模型 对象方法*/
//    Person *per4 = [[Person alloc] sxInitBaseModelJson:jsonString];
//    /*通过掉用 对象方法获取相应的数据模型*/
//    per4.cars = (NSMutableArray *)[per4 sxBaseModelClass:[Car new].class dataArr:cars];
//
//    per3.cars = (NSMutableArray *)[Car sxBaseModelDataArr:cars];
//
//    per3.muDict = [[NSMutableDictionary alloc] initWithDictionary:@{@"name":@"这个是车",@"car":per3.car,@"array":cars,@"set":[NSSet setWithArray:cars]}];
//
//    per3.set = [NSSet setWithArray:cars];
//    CGRect rect = CGRectMake(201, 300, 50, 80);
//    NSValue *rectValue = [NSValue valueWithCGRect:rect];
//    per3.rect = rect;
//    CGSize size = CGSizeMake(100, 100);
//    per3.size = size;
//    NSDictionary *objToDict = [per3 dictFromObj];
//
//
//    Person *per6 = [Person sxBaseModelDictionry:objToDict];
//
//    NSDictionary *objTo6 = [per6 dictFromObj];
//    NSDictionary *objTo7 = [Person dictFromNeedObj:per6];
//
//    PersonMan *per8 = [PersonMan sxBaseModelDictionry:dict];
//    NSDictionary *objDict8 = [per8 dictFromObj];
//    NSDictionary *mdddDict = [self dictFromdictObj:per3.muDict];
//    NSArray *arrObj = @[(per3.car),per3.cars];
//    NSArray *arrObjToArr = [self arrayFromArrObj:arrObj];
   
}



@end
